//
//  AllOrderTableViewCell.m
//  FruitVIP
//
//  Created by 孙艳玲 on 15/5/26.
//  Copyright (c) 2015年 孙艳玲. All rights reserved.
//

#import "AllOrderTableViewCell.h"

#define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width)
#define SCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height)

@implementation AllOrderTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSub];
    }
    return self;
}

- (void)createSub
{
    
    UILabel *listTimeLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, SCREEN_WIDTH / 5,SCREEN_HEIGHT/15)];
    listTimeLabel.text = @"下单时间:";
    listTimeLabel.textColor = [UIColor lightGrayColor];
    listTimeLabel.font = [UIFont systemFontOfSize:13];
//    listTimeLabel.backgroundColor = [UIColor yellowColor];
    [self.contentView addSubview:listTimeLabel];
    
    UILabel *detailListTimeLabel = [[UILabel alloc] initWithFrame:CGRectMake(listTimeLabel.frame.origin.x + listTimeLabel.frame.size.width, listTimeLabel.frame.origin.y, SCREEN_WIDTH - 20 - listTimeLabel.frame.size.width, listTimeLabel.frame.size.height)];
    detailListTimeLabel.text = @"2015/5/18 11:15:30";
    detailListTimeLabel.textColor = [UIColor grayColor];
    detailListTimeLabel.font = [UIFont systemFontOfSize:13];
    [self.contentView addSubview:detailListTimeLabel];
    
    
    UILabel *lineLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, listTimeLabel.frame.origin.y + listTimeLabel.frame.size.height, SCREEN_WIDTH - 20, 0.1)];
    lineLabel.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:lineLabel];
    
    self.waitImageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, listTimeLabel.frame.origin.y + listTimeLabel.frame.size.height +  5, SCREEN_WIDTH / 3.2, SCREEN_WIDTH / 3.2)];
//    waitImageView.backgroundColor = [UIColor yellowColor];
    self.waitImageView.userInteractionEnabled = YES;
    UIImage *image = [UIImage imageNamed:@"detailFood.png"];
    self.waitImageView.image = image;
    self.waitImageView.contentMode = UIViewContentModeScaleAspectFit;
    [self.contentView addSubview:self.waitImageView];
    
    UILabel *timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.waitImageView.frame.origin.x + self.waitImageView.frame.size.width + 10, self.waitImageView.frame.origin.y ,  2 * self.waitImageView.frame.size.width / 3 - 5, self.waitImageView.frame.size.height / 6)];
    //    timeLabel.backgroundColor = [UIColor redColor];
    timeLabel.text = @"订单编号:";
    timeLabel.font = [UIFont systemFontOfSize:13];
    timeLabel.textColor = [UIColor lightGrayColor];
    [self.contentView addSubview:timeLabel];
    
    UILabel *detailTimeLabel = [[UILabel alloc] initWithFrame:CGRectMake(timeLabel.frame.origin.x + timeLabel.frame.size.width , timeLabel.frame.origin.y, SCREEN_WIDTH - 20 - self.waitImageView.frame.size.width - timeLabel.frame.size.width , timeLabel.frame.size.height)];
    //    detailTimeLabel.backgroundColor = [UIColor blueColor];
    detailTimeLabel.text = @"87548454";
    detailTimeLabel.font = [UIFont systemFontOfSize:13];
    detailTimeLabel.textColor = [UIColor grayColor];
    [self.contentView addSubview:detailTimeLabel];
    
    UILabel *payLabel = [[UILabel alloc] initWithFrame:CGRectMake(timeLabel.frame.origin.x, timeLabel.frame.origin.y + timeLabel.frame.size.height + 5, timeLabel.frame.size.width, timeLabel.frame.size.height)];
    payLabel.text = @"订单状态:";
    payLabel.font = [UIFont systemFontOfSize:13];
    payLabel.textColor = [UIColor lightGrayColor];
    [self.contentView addSubview:payLabel];
    
    self.detailPayLabel = [[UILabel alloc] initWithFrame:CGRectMake(detailTimeLabel.frame.origin.x, payLabel.frame.origin.y, detailTimeLabel.frame.size.width, payLabel.frame.size.height)];
//    self.detailPayLabel.text = @"未支付";
    self.detailPayLabel.font = [UIFont systemFontOfSize:13];
    self.detailPayLabel.textColor = [UIColor grayColor];
    [self.contentView addSubview:self.detailPayLabel];
    
    UILabel *moneyLabel = [[UILabel alloc] initWithFrame:CGRectMake(payLabel.frame.origin.x, payLabel.frame.origin.y + payLabel.frame.size.height + 5, payLabel.frame.size.width, payLabel.frame.size.height)];
    moneyLabel.text = @"订单金额:";
    moneyLabel.font = [UIFont systemFontOfSize:13];
    moneyLabel.textColor = [UIColor lightGrayColor];
    [self.contentView addSubview:moneyLabel];
    
   self.allMoneyLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.detailPayLabel.frame.origin.x, moneyLabel.frame.origin.y, self.detailPayLabel.frame.size.width, self.detailPayLabel.frame.size.height)];
    self.allMoneyLabel.textColor = [UIColor blackColor];
//    self.allMoneyLabel.backgroundColor = [UIColor redColor];
    self.allMoneyLabel.text = @"79.00";
    self.allMoneyLabel.font = [UIFont systemFontOfSize:13];
    NSString *str = @"￥";
   self. allMoneyLabel.text = [str stringByAppendingString:self.allMoneyLabel.text];
    [self.contentView addSubview:self.allMoneyLabel];
    
    
    self.payButton = [UIButton buttonWithType:UIButtonTypeCustom];
    self.payButton.frame = CGRectMake(SCREEN_WIDTH - (SCREEN_WIDTH - 20) / 3 , self.allMoneyLabel.frame.origin.y + self.allMoneyLabel.frame.size.height + 5, (SCREEN_WIDTH - 20) / 4, self.waitImageView.frame.size.height / 3);
    self.payButton.backgroundColor = [UIColor colorWithRed:242.0 / 255.0 green:204.0 / 255.0 blue:49.0 / 255.0 alpha:1];
    self.payButton.titleLabel.font = [UIFont systemFontOfSize:13];
    [self.payButton setTitleColor:[UIColor colorWithRed:71.0 / 255.0 green:61.0 / 255.0 blue:55.0 / 255.0 alpha:1] forState:UIControlStateNormal];
    self.payButton.layer.cornerRadius = CGRectGetHeight([self.payButton bounds])/2;
    [self.payButton addTarget:self action:@selector(payButtonAction) forControlEvents:UIControlEventTouchUpInside];
    [self.contentView addSubview:self.payButton];

}


- (void)payButtonAction
{
    NSLog(@"立即支付");
    [self.myDelegate payJust:self.allMoneyLabel.text];
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
